package com.qhg.saas_server.controller;


import com.qhg.saas_server.empty.Result;
import com.qhg.saas_server.pojo.Prisystem;
import com.qhg.saas_server.service.PrisystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

;

/**
 *@作者:lsk
 *Controller接口
 *@Date:2023/07/18
*/
@CrossOrigin
@RestController
@RequestMapping("/PrisystemURL")
public class PrisystemController {


	@Autowired
	private PrisystemService prisystemservice;


	/**
	根据PriSystemId查询
	*/
	@GetMapping("/selectByPriSystemId/{priSystemId}")
	public Result selectByPriSystemId(@PathVariable(value = "priSystemId") Integer priSystemId){
		return Result.success(prisystemservice.selectByPriSystemId(priSystemId));
	}


	/**
	根据PriSystemId更新
	*/
	@PostMapping("/updateByPriSystemId")
	public Result updateByPriSystemId(@RequestBody Prisystem demo){
		return Result.success(prisystemservice.updateByPriSystemId( demo));
	}



	/**
	根据PriSystemId删除
	*/
	@GetMapping("/deleteByPriSystemId/{priSystemId}")
	public Result deleteByPriSystemId(@PathVariable(value = "priSystemId") Integer priSystemId){
		return Result.success(prisystemservice.deleteByPriSystemId(priSystemId));
	}





	/**
	 insert:(插入)
	*/
	@PostMapping("/insert")
	public Result insert(@RequestBody Prisystem demo){
		Result.success(prisystemservice.insert(demo));
		return Result.success(demo);
	}



	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	@PostMapping("/insertOrUpdate")
	public Result insertOrUpdate(@RequestBody Prisystem demo){
		return Result.success(prisystemservice.insertOrUpdate(demo));
	}



	/**
	 insertBath:(批量插入)
	*/
	@PostMapping("/insertBatch")
	public Result insertBatch(@RequestBody List<Prisystem> list){
		return Result.success(prisystemservice.insertBatch(list));
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	@PostMapping("/insertOrUpdateBatch")
	public Result insertOrUpdateBatch(@RequestBody List<Prisystem> list){
		return Result.success(prisystemservice.insertOrUpdateBatch(list));
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	@PostMapping("/selectList")
	public Result selectList(@RequestBody Map<String,Object> param){
		Map map = new HashMap<String,Object>();
		if(param.get("pageNum") != null){
			map.put("total",prisystemservice.selectCount(param));
		}
		map.put("data",prisystemservice.selectList(param));
		return Result.success(map);
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	@PostMapping("/selectCount")
	public Result selectCount(@RequestBody Map<String,Object> param){
		return Result.success(prisystemservice.selectCount(param));
	}



}